package day04;
import java.util.Scanner;
public class Guessing {
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int answer=(int)(Math.random()*1000+1);

        int num;
        int a=0;
        do{
            System.out.println("请输入您猜的值：");
            // num=scan.nextInt();
            num=a;
            System.out.println(num);
            if(num<answer){
                System.out.println("猜小了");
                a++;
            }else if(num>answer){
                System.out.println("猜大了");
            }else {
                System.out.println("恭喜你猜对了!");
                System.out.println("答案为："+num);
            }
        }while (num!=answer);








        /*Scanner scan=new Scanner(System.in);
        System.out.println("请输入您猜的值：");
        int num=scan.nextInt();
        int answer=(int)(Math.random()*1000+1);
         while (num!=answer){
             if (num>answer){
                 System.out.println("对不起，猜大了!");
             }else{
                 System.out.println("对不起，猜小了!");
             }
             System.out.println("请重新猜：");
             num=scan.nextInt();
         }
        System.out.println("恭喜你，猜对了!!");*/


    }
}
